package com.katus.tileserver.util;

/**
 * @author Keran Sun (katus)
 * @version 1.0, 2020-09-24
 */
public class CoorCal {
    public static double tile2Lat(int y, int z) {
        int n = 1 << z;
//        lat_rad = math.atan(math.sinh(math.pi * (1 - 2 * ytile / n)))
//        lat_deg = math.degrees(lat_rad)
//        return 1.0 * y / n * 180 - 90;
        return Math.toDegrees(Math.atan(Math.sinh(Math.PI * (1 - 2.0*y / n))));
    }

    public static double tile2Lon(int x, int z) {
        int n = 1 << z;
        return 1.0 * x / n * 360 - 180;
    }
}
